package com.fish.admin.module.salesman.controller;

import com.fish.admin.module.salesman.domain.dto.SalesmanInfoDTO;
import com.fish.admin.module.salesman.domain.dto.SalesmanInfoPageQueryDTO;
import com.fish.admin.module.salesman.domain.vo.SalesmanInfoVO;
import com.fish.admin.module.salesman.service.SalesmanInfoService;
import com.fish.common.core.domain.vo.PageVO;
import com.fish.common.core.response.RestResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequiredArgsConstructor
@RestController
@RequestMapping("/api/salesman/info")
public class SalesmanInfoController {

    private final SalesmanInfoService salesmanInfoService;

    /**
     * 分页获取业务员
     * @param salesmanInfoPageQueryDTO
     * @return
     */
    @PostMapping("/v1/page")
    public RestResponse<PageVO<SalesmanInfoVO>> page(
            @RequestBody SalesmanInfoPageQueryDTO salesmanInfoPageQueryDTO) {
        return RestResponse.ok(salesmanInfoService.page(salesmanInfoPageQueryDTO));
    }

    /**
     * @Title: save @Description: 新增
     * @param salesmanInfoDTO
     * @return RestResponse
     */
    @PostMapping("/v1/save")
    public RestResponse save(@RequestBody SalesmanInfoDTO salesmanInfoDTO) {
        salesmanInfoService.save(salesmanInfoDTO);
        return RestResponse.ok();
    }
}
